import { defineConfig } from 'umi';
import routes from "./routes";
import layoutDefaultSettings from "./layoutDefaultSettings";
import proxy from './proxy';

const { REACT_APP_ENV } = process.env;

export default defineConfig({
  define: {
    'process.env.BASE_URL': '/api',
    'process.env.AUTH_URL': '/auth',
  },
  externals: {
    react: "var window.React",
    "react-dom": "var window.ReactDOM",
    "prop-types": "var window.PropTypes",
    "@alifd/next": "var window.Next",
    moment: "var window.moment",
    lodash: "var window._",
  },
  chainWebpack:(config) =>{
    config.module
        .rule('ejs')
        .test(/\.(ejs)$/)
        .use('ejs-loader')
        .loader('ejs-loader')
        .options({  
          esModule: false, 
        })
        .end();
  },
  routes,
  hash: true,
  locale:{
    default: 'zh-CN',
    antd: true,
    title: false,
    baseNavigator: true,
    baseSeparator: '-',
  },
  dva:{
    hmr:true,
    immer:false
  },
  nodeModulesTransform: {
    type: 'none',
    exclude: [],
  },
  devServer: {
    port: 8130,
    open: true,
  },
  dynamicImportSyntax: {},
  fastRefresh: {},
  theme:{
    'primary-color': layoutDefaultSettings.primaryColor,
  },
  qiankun: {
      master: {
        apps: [
          {
            name: 'account',
            entry: 'http://localhost:8151',
            // entry: 'http://localhost:8130/account-app/index.html',
          },
          {
            name: 'oss',
            entry: 'https://cloud.vizards.cc/ming/oss/index.html'
          },
      ]
      },
    },
    proxy: proxy[REACT_APP_ENV || 'dev'],
});
